import requests
from bs4 import BeautifulSoup
base_url = "https://movie.douban.com/top250"
header = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"}
response = requests.get(base_url,headers=header)
response.encoding = "utf-8"
# print(response.text)
# 解析网页
soup = BeautifulSoup(response.text,features="html.parser")
items = soup.select(".item")
# 遍历所有的item
for item in items:
    title = item.select(".hd>a")[0].text
    title = "/".join([i.strip() for i in title.split("/")])
    rating_num = item.select(".rating_num")[0].text
    quote = item.select(".quote")[0].text.strip()
    print(title)
    print(rating_num)
    print(quote)